package com.product.service.impl;

import com.product.Dao.ProductDao;
import com.product.Dao.impl.ProductDaoImpl;
import com.product.exception.AppException;
import com.product.exception.SelectNotException;
import com.product.pojo.Product;
import com.product.service.ProductService;

import java.util.List;

public class ProductServiceImpl implements ProductService {
    private  ProductDao productDao=new ProductDaoImpl();
    public  List<Product> findAll() throws SelectNotException, AppException {
        //直接调用查询所有方法
            List<Product> list=productDao.selectAll();
        return list;
    }
    public Product findOne(String name) throws SelectNotException, AppException{
        Product product=productDao.selectByProductName(name);
        return product;
    }
    public int upDate(Product product) throws SelectNotException, AppException{
        int count=productDao.update(product);
        return count;
    }

    public int delete(int id) throws SelectNotException, AppException{
        int count=productDao.deleteById(id);
        return count;
    }
    public int add(Product product) throws SelectNotException, AppException{
        int count=productDao.insert(product);
        return count;
    }
}
